import HomeApi from '~/api/home'

export const state = () => ({
  data: {}
})

export const mutations = {
  SAVE_DATA(state, payload) {
    state.data = payload
  },
  UPDATE_DATA(state, payload) {
    console.log('更新vuex中的数据', state, payload)
    const { key, data } = payload
    state.data[key] = data
  }
}

export const actions = {
  getData({ commit }) {
    return HomeApi.getData().then((res) => {
      commit('SAVE_DATA', res.data.data)
    })
  }
}

export const getters = {}
